

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief" lay-filter="tabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">聊天记录</li>
                <li>账户禁言记录</li>
                <li>聊天设置</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">用户名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="nick_name" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">账号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="account" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">用户状态</label>
                                <div class="layui-input-block">
                                    <select name="status">
                                        <option value="">全部</option>
                                        <option value="0">正常登录</option>
                                        <option value="1">禁言</option>
                                        <option value="2">永久禁言</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">发言时间</label>
                                <div class="layui-input-inline" style="width: 350px;">
                                    <input type="text" name="start_time" placeholder="开始时间" autocomplete="off" class="layui-input" style="width: 167px;display: inline" id="start_time_input">
                                    -
                                    <input type="text" name="end_time" placeholder="截止时间" autocomplete="off" class="layui-input" style="width: 167px;display: inline" id="end_time_input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-orderlist" lay-submit lay-filter="LAY-order-front-search">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table id="LAY-ads-applaunch-manage" lay-filter="LAY-ads-applaunch-manage"></table>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">用户名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="nick_name" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">操作人</label>
                                <div class="layui-input-block">
                                    <input type="text" name="admin_name" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">发言时间</label>
                                <div class="layui-input-inline" style="width: 350px;">
                                    <input type="text" name="start_time" placeholder="开始时间" autocomplete="off" class="layui-input" style="width: 167px;display: inline" id="start_time_input">
                                    -
                                    <input type="text" name="end_time" placeholder="截止时间" autocomplete="off" class="layui-input" style="width: 167px;display: inline" id="end_time_input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-orderlist" lay-submit lay-filter="LAY-order-front2-search">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table id="LAY-ads-apphome-manage" lay-filter="LAY-ads-apphome-manage"></table>
                </div>
                <div class="layui-tab-item">

                    <div class="layui-form  layuiadmin-card-header-auto" style="min-height: 600px" wid100="" lay-filter="">
                        <div class="layui-form-item text-center">
                            <p>* 发言频率</p>
                        </div>
                        {volist name="rule" id="vo"}
                        <div class="layui-form-item rule">
                            <label class="layui-form-label sort">{$vo.id}.</label>
                            <div class="layui-input-inline">
                                <input type="text" name="second" value="{$vo['second']}" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                <label class="layui-form-label">秒内发言</label>
                            </div>

                            <div class="layui-input-inline">
                                <input type="text" name="time" value="{$vo.time}" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                <label class="layui-form-label">次，自动禁言</label>
                            </div>

                            <div class="layui-input-inline">
                                <input type="text" name="minute" value="{$vo.minute}" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                <label class="layui-form-label">分钟</label>
                            </div>

                        </div>
                        {/volist}

                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn withdrawals-add">添加禁言规则</button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" style="float: right" lay-filter="withdrawals-confirm">提交</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <script type="text/html" id="table-adslist-ads">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon"></i>禁言</a>
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="del"><i class="layui-icon"></i>解除禁言</a>
            </script>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    var setCount = parseInt('{$count}')+1;
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'admin', 'chat','laydate'], function () {
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin
            ,laydate = layui.laydate
            ,table = layui.table;

        //事件
        var active = {
            add: function(){
                layer.open({
                    type: 2
                    ,title: '添加广告'
                    ,content: '/admin/ads/appadd'
                    ,maxmin: true
                    ,area: ['650px', '450px']
                });
            }
        };

        laydate.render({
            elem: '#start_time_input',
            type: 'date',
            format: 'yyyy-MM-dd 00:00:00'
        });

        laydate.render({
            elem: '#end_time_input',
            type: 'date',
            format: 'yyyy-MM-dd 00:00:00'
        });

        $('.layui-btn.layuiadmin-btn-ads').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        //监听搜索
        form.on('submit(LAY-order-front-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-ads-applaunch-manage', {
                where: field
                , page: {
                    curr: 1   //默认从第一页开始搜索
                },
            });
            return false;
        });

        //监听搜索
        form.on('submit(LAY-order-front2-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-ads-apphome-manage', {
                where: field
                , page: {
                    curr: 1   //默认从第一页开始搜索
                },
            });
            return false;
        });


        $('.withdrawals-add').click(function(obj){
            let SELF = $(this);
            $('.rule:last').clone().insertAfter('.rule:last').find('.sort').html((setCount++).toString() + '.').parent().find('input[name=time],input[name=minute],input[name=second]').val('');
        });
        form.on('submit(withdrawals-confirm)', function(obj){
            let data = []
            let index = 1;
            $('.rule').each(function (d){
                let SELF = $(this);
                let time = SELF.find('input[name=time]').val();
                if (time) {
                    let obj = {
                        'id':index++,
                        'time':time,
                        'minute':SELF.find('input[name=minute]').val(),
                        'second':SELF.find('input[name=second]').val(),
                    }
                    data.push(obj)
                }

            })

            //提交
            admin.req({
                url: '/admin/chat/edit_post'
                ,data: {'data':JSON.stringify(data)}
                ,success: function(res){
                    if (res.code == 0){
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
